import Request from '@/utils/request'

export function getList(data,page) {
  return Request({
    url: '/api/admin/role/list/' + page.offset + "/" + page.limit,
    method: 'POST',
    data
  })
}

export function update(data) {
  return Request({
    url: '/api/admin/role/update',
    method: 'post',
    data: data
  })
}

export function add(data) {
  return Request({
    url: '/api/admin/role/add',
    method: 'post',
    data: data
  })
}

export function del(data) {
  return Request({
    url: '/api/admin/role/del',
    method: 'post',
    data: data
  })
}

//更新角色的权限
export function updatePer(data) {
  return Request({
    url: '/api/admin/role/updatePer',
    method: 'post',
    data: data
  })
}

//查询角色的权限
export function findByRoleId(roleId) {
  return Request({
    url: '/api/admin/per/role/' + roleId,
    method: 'get'
  })
}

//查询角色单个角色
export function getRole(roleId) {
  return Request({
    url: '/api/admin/role/' + roleId,
    method: 'get'
  })
}

//修改角色状态
export function changeRoleDisable(data) {
  return Request({
    url: '/api/admin/role/changeDisable',
    method: 'post',
    data
  })
}

//获取角色的Excel文件
export function getRoleExcel() {
  return Request({
    url: '/api/admin/role/export',
    method: 'post',
    responseType: 'blob',
  })
}

//获取拥有该角色的用户
export function getUserByRoleId(data) {
  return Request({
    url: '/api/admin/role/find/user/',
    method: 'post',
    data
  })
}

//删除角色下面的用户
export function authUserCancel(data) {
  return Request({
    url: '/api/admin/role/cancelAuth',
    method: 'post',
    data
  })
}

//给角色添加用户
export function addRoleToUsers(data) {
  return Request({
    url: '/api/admin/role/add/user',
    method: 'post',
    data
  })
}
